package com.example.culturapp;

import java.util.ArrayList;

import android.app.ActionBar;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class PerfilUsuarioActivity extends ActionBarActivity{
	private GridView gridView; 
	private ArrayList<Item> gridArray = new ArrayList<Item>(); 
	private CustomGridViewAdapter customGridAdapter;
	private CheckBox checkBox;
	private TextView tvRangoHorario;
	private EditText etHr1;
	private EditText etHr2;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final ActionBar actionBar = getActionBar();
		actionBar.setIcon(R.drawable.ico);
		actionBar.setDisplayShowTitleEnabled(false);
		actionBar.setDisplayHomeAsUpEnabled(false);
		
		setContentView(R.layout.perfilusuario); 
		
		Bitmap personaIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.personal); 
		Bitmap charlyIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.charly); 
		Bitmap indioIcon = BitmapFactory.decodeResource(this.getResources(), R.drawable.indio_solari);
		gridArray.add(new Item(personaIcon,"ARTISTAS")); 
		gridArray.add(new Item(charlyIcon,"CABA")); 
		gridArray.add(new Item(indioIcon,"Cordoba"));  
		
		gridView = (GridView) findViewById(R.id.gridView1); 
		this.checkBox= (CheckBox) findViewById(R.id.cbRecibirNots);
	    this.etHr1= (EditText) findViewById(R.id.etHr1);
	    this.etHr2= (EditText) findViewById(R.id.etHr2);
	    this.tvRangoHorario= (TextView) findViewById(R.id.tvRangoHorario);
		
		customGridAdapter = new CustomGridViewAdapter(this, R.layout.row_grid, gridArray); 
		gridView.setAdapter(customGridAdapter); 
		
		gridView.setOnItemClickListener(new OnItemClickListener() { 	
			@Override 
			public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { 
				Toast.makeText(getApplicationContext(),gridArray.get(position).getTitle(), Toast.LENGTH_SHORT).show(); } }); 
	}

	public void EvaluarCB(View v){
    	if(checkBox.isChecked()){
    		etHr1.setEnabled(true);
    		etHr2.setEnabled(true);
    		tvRangoHorario.setEnabled(true);
    	} else {
    		etHr1.setEnabled(false);
    		etHr2.setEnabled(false);
    		tvRangoHorario.setEnabled(false);	
    	}
	}
}
